﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LedgerMonthlyWithPeriod.aspx.cs"
    Inherits="Main_Reports_Accounts_LedgerMonthlyWithPeriod" Culture="en-GB" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Monthly Ledger Details</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
        function ValidationBlank() {
            if (document.getElementById("ddlLedger").value == "-1") {
                alert('Specify Ledger for Details!');
                document.getElementById("ddlLedger").focus();
                return false;
            }
            else if (document.getElementById("txtFromDate").value == '') {
                alert('Specify From date!');
                document.getElementById("txtFromDate").focus();
                return false;
            }
            else if (document.getElementById("txtToDate").value == '') {
                alert('Specify To Date!');
                document.getElementById("txtToDate").focus();
                return false;
            }
            else {
                var strFromDate = document.getElementById("txtFromDate").value;
                var strToDate = document.getElementById("txtToDate").value;
                var dtFrom = parseInt(strFromDate.substring(0, 2), 10);
                var monFrom = parseInt(strFromDate.substring(3, 5), 10);
                var yrFrom = parseInt(strFromDate.substring(6, 10), 10);
                var dtTo = parseInt(strToDate.substring(0, 2), 10);
                var monTo = parseInt(strToDate.substring(3, 5), 10);
                var yrTo = parseInt(strToDate.substring(6, 10), 10);
                var dateFrom = new Date(yrFrom, monFrom, dtFrom);
                var dateTo = new Date(yrTo, monTo, dtTo);
                if (dateTo < dateFrom) {
                    alert("To date cannot be greater than from date");
                    document.getElementById("txtToDate").focus();
                    return false;
                }
                else {
                    return true;
                }
            }
        }
        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
        function getWidth() {
            document.getElementById("hidChartWidth").value = document.getElementById("grdDisplay").clientWidth; 
        }      
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div style="width: 90%; margin-left: 5%; margin-right: 5%; margin-top: 7px;">
        <asp:HiddenField ID="hidChartWidth" runat="server" Value="0" />
        <asp:Panel ID="panelMenu" Width="100%" runat="server">
            <div style="width: 60%; margin-left: 20%; margin-right: 20%; margin-top: 7px;">
                <table width="100%" class="tablecontent">
                    <tr>
                        <td colspan="2" align="center" style="width: 100%" class="headtd">
                            Periodic Ledger Details
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 40%; padding-top: 10px;" align="right" valign="top">
                            Choose Ledger :
                        </td>
                        <td style="width: 60%; padding-top: 10px; padding-left: 3px;" align="left" valign="top">
                            <asp:DropDownList ID="ddlLedger" runat="server" CssClass="dropdown">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 40%;" align="right" valign="top">
                            From Date :
                        </td>
                        <td style="width: 60%; padding-left: 3px;" align="left" valign="top">
                            <asp:TextBox ID="txtFromDate" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                            <asp:ImageButton ID="imgFromDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                            <advancedCalender:CalendarExtenderPlus ID="calFromDate" runat="server" PopupButtonID="imgFromDate"
                                Format="dd/MM/yyyy" TargetControlID="txtFromDate">
                            </advancedCalender:CalendarExtenderPlus>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 40%;" align="right" valign="top">
                            To Date :
                        </td>
                        <td style="width: 60%; padding-left: 3px;" align="left" valign="top">
                            <asp:TextBox ID="txtToDate" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                            <asp:ImageButton ID="imgToDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                            <advancedCalender:CalendarExtenderPlus ID="calToDate" runat="server" PopupButtonID="imgToDate"
                                Format="dd/MM/yyyy" TargetControlID="txtToDate">
                            </advancedCalender:CalendarExtenderPlus>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100%; padding-left: 3px;" align="center" colspan="2" valign="top">
                            <asp:Button ID="btnShow" runat="server" Text="Show" CssClass="button" OnClick="btnShow_Click"
                                OnClientClick="return ValidationBlank();" />
                            &nbsp;
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" OnClick="btnCancel_Click" />
                        </td>
                    </tr>
                </table>
            </div>
        </asp:Panel>
        <asp:Panel ID="panelView" runat="server" Width="100%" Style="margin-top: 5px;" Visible="false">
            <table style="border: solid 1px #818181;" width="97%">
                <tr>
                    <td style="margin-top: 7px; padding-right: 5px;" valign="top" align="right">
                        <asp:LinkButton ID="lnkBack" runat="server" Text="Back" OnClick="lnkBack_Click"></asp:LinkButton>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100%;" class="headtd" align="center">
                        <asp:Label ID="lblHeading" runat="server" Font-Bold="true"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100%">
                        <asp:GridView ID="grdDisplay" CssClass="gridview" Width="100%" runat="server" OnRowDataBound="grdDisplay_RowDataBound"
                            AutoGenerateColumns="false" ShowFooter="true">
                            <Columns>
                                <asp:BoundField DataField="MonthName" HeaderText="Month" ItemStyle-Width="25%" />
                                <asp:TemplateField HeaderText="Debit" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="25%">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDebit" runat="server" Text='<%# Eval("Debit")%>'></asp:Label>
                                        <asp:HiddenField ID="hidDebit" runat="server" Value='<%# Eval("Debit")%>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Credit" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="25%">
                                    <ItemTemplate>
                                        <asp:Label ID="lblCredit" runat="server" Text='<%# Eval("Credit")%>'></asp:Label>
                                        <asp:HiddenField ID="hidCredit" runat="server" Value='<%# Eval("Credit")%>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Balance" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="25%">
                                    <ItemTemplate>
                                        <asp:Label ID="lblBalance" runat="server"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>
            <br />
            <%--<asp:Chart ID="monthlyChart" runat="server" Visible="false" Width="750" BorderlineWidth="1"
                BorderlineColor="ActiveBorder" Height="200" ToolTip="Monthly Summary" ImageLocation="~/TempImageFiles">
                <Series>
                    <asp:Series Name="Series1" XValueMember="MonthName" YValueMembers="BalanceForChart"
                        Color="#63a83b">
                    </asp:Series>
                </Series>
                <ChartAreas>
                    <asp:ChartArea  Name="ChartArea1">
                        <AxisY Title="Amount">
                        </AxisY>
                        <AxisX  IsLabelAutoFit="true">
                            <LabelStyle Angle="-90" Interval="1" />
                        </AxisX>
                    </asp:ChartArea>
                </ChartAreas>
            </asp:Chart>--%>
        </asp:Panel>
    </div>
    </form>
</body>
</html>
